<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.Workshop;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.Workshop">
		<cfargument name="Workshop_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.Workshop_ID gt 0) {
				local.args = {};
				local.args.obj = new Workshop();
				StructAppend(local.args, queryToStruct(read(argumentCollection = arguments))[1]);
				/* 
				structure of local.loadArgs is...
				s.obj = blank Workshop object which is loaded with the following properties
				s.Workshop_ID = 123
				s.Organization_ID = 123
				s.etc... for all properties in workshop
				*/
				return load(argumentCollection = local.args);
			} else {
				return new Workshop();
			}
		</cfscript>
	</cffunction>
	
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.Workshop">
		<cfargument name="obj" type="assets.calgrants.com.bo.Workshop" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.Workshop_ID")) {
				local.obj.setWorkshop_ID(arguments.Workshop_ID);
			}
			if (IsDefined("arguments.Program_Year")) {
				local.obj.setProgram_Year(arguments.Program_Year);
			}
			if (IsDefined("arguments.Approved")) {
				local.obj.setApproved(arguments.Approved);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.Organization_ID")) {
				local.obj.setOrganization_ID(arguments.Organization_ID); 
			}
			if (IsDefined("arguments.Organizer_ID")) {
				local.obj.setOrganizer_ID(arguments.Organizer_ID);
			}
			if (IsDefined("arguments.Site_ID")) {
				local.obj.setSite_ID(arguments.Site_ID);
			}
			if (IsDefined("arguments.Manager_ID")) {
				local.obj.setManager_ID(arguments.Manager_ID);
			}
			if (IsDefined("arguments.Workshop_Date")) {
				local.obj.setWorkshop_Date(arguments.Workshop_Date);
			}
			if (IsDefined("arguments.Start_Time")) {                             
				local.obj.setStart_Time(arguments.Start_Time);
			}
			if (IsDefined("arguments.End_Time")) {
				local.obj.setEnd_Time(arguments.End_Time);
			}
			if (IsDefined("arguments.Evaluation_Code")) {
				local.obj.setEvaluation_Code(arguments.Evaluation_Code);
			}
			if (IsDefined("arguments.PB_Survey_Count")) {                             
				local.obj.setPB_Survey_Count(arguments.PB_Survey_Count);
			}
			if (IsDefined("arguments.PB_Survey_Count_Status")) {
				local.obj.setPB_Survey_Count_Status(arguments.PB_Survey_Count_Status);
			}
			if (IsDefined("arguments.PB_Shipped_Date")) {
				local.obj.setPB_Shipped_Date(arguments.PB_Shipped_Date);
			}
			if (IsDefined("arguments.PB_Notes")) {
				local.obj.setPB_Notes(arguments.PB_Notes);
			}
			if (IsDefined("arguments.Anticipated_Students")) {
				local.obj.setAnticipated_Students(arguments.Anticipated_Students);
			}
			if (IsDefined("arguments.Anticipated_Volunteers")) {
				local.obj.setAnticipated_Volunteers(arguments.Anticipated_Volunteers);
			}
			if (IsDefined("arguments.Anticipated_Computers")) {
				local.obj.setAnticipated_Computers(arguments.Anticipated_Computers);
			}
			if (IsDefined("arguments.Financial_Aid_Presentation")) {
				local.obj.setFinancial_Aid_Presentation(arguments.Financial_Aid_Presentation);
			}
			if (IsDefined("arguments.FAFSA_On_The_Web")) {
				local.obj.setFAFSA_On_The_Web(arguments.FAFSA_On_The_Web);
			}
			if (IsDefined("arguments.Online")) {
				local.obj.setOnline(arguments.Online);
			}
			if (IsDefined("arguments.Offline_Reasons")) {
				local.obj.setOffline_Reasons(arguments.Offline_Reasons);
			}
			if (IsDefined("arguments.Small_Group")) {
				local.obj.setSmall_Group(arguments.Small_Group);
			}
			if (IsDefined("arguments.Scholarship_Assistance")) {
				local.obj.setScholarship_Assistance(arguments.Scholarship_Assistance);
			}
			if (IsDefined("arguments.Tax_Assistance")) {
				local.obj.setTax_Assistance(arguments.Tax_Assistance);
			}
			if (IsDefined("arguments.Separate_Areas")) {
				local.obj.setSeparate_Areas(arguments.Separate_Areas);
			}
			if (IsDefined("arguments.AB540")) {
				local.obj.setAB540(arguments.AB540);
			}
			if (IsDefined("arguments.Foster_Youth")) {
				local.obj.setFoster_Youth(arguments.Foster_Youth);
			}
			if (IsDefined("arguments.Alt_Language_Workshop")) {
				local.obj.setAlt_Language_Workshop(arguments.Alt_Language_Workshop);
			}
			if (IsDefined("arguments.Alt_Languages")) {
				local.obj.setAlt_Languages(arguments.Alt_Languages);
			}
			if (IsDefined("arguments.Translators")) {
				local.obj.setTranslators(arguments.Translators);
			}
			if (IsDefined("arguments.Translator_Languages")) {
				local.obj.setTranslator_Languages(arguments.Translator_Languages);
			}
			if (IsDefined("arguments.Refreshments")) {
				local.obj.setRefreshments(arguments.Refreshments);
			}
			if (IsDefined("arguments.Child_Care")) {
				local.obj.setChild_Care(arguments.Child_Care);
			}
			if (IsDefined("arguments.Other_Services")) {
				local.obj.setOther_Services(arguments.Other_Services);
			}
			if (IsDefined("arguments.Other_Services_Description")) {
				local.obj.setOther_Services_Description(arguments.Other_Services_Description);
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="Workshop_ID" required="false" default="" />
		<cfargument name="Program_Year" required="false" default="" />
		<cfargument name="Approved" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Organization_ID" required="false" default="" />
		<cfargument name="Organizer_ID" required="false" default="" />
		<cfargument name="Site_ID" required="false" default="" />
		<cfargument name="Manager_ID" required="false" default="" />
		<cfargument name="Workshop_Date" required="false" default="" />
		<cfargument name="Start_Time" required="false" default="" />
		<cfargument name="End_Time" required="false" default="" />
		<cfargument name="Evaluation_Code" required="false" default="" />
		<cfargument name="PB_Survey_Count" required="false" default="" />
		<cfargument name="PB_Survey_Count_Status" required="false" default="" />
		<cfargument name="PB_Shipped_Date" required="false" default="" />
		<cfargument name="PB_Notes" required="false" default="" />
		<cfargument name="Anticipated_Students" required="false" default="" />
		<cfargument name="Anticipated_Volunteers" required="false" default="" />
		<cfargument name="Anticipated_Computers" required="false" default="" />
		<cfargument name="Financial_Aid_Presentation" required="false" default="" />
		<cfargument name="FAFSA_On_The_Web" required="false" default="" />
		<cfargument name="Online" required="false" default="" />
		<cfargument name="Offline_Reasons" required="false" default="" />
		<cfargument name="Small_Group" required="false" default="" />
		<cfargument name="Scholarship_Assistance" required="false" default="" />
		<cfargument name="Tax_Assistance" required="false" default="" />
		<cfargument name="Separate_Areas" required="false" default="" />
		<cfargument name="AB540" required="false" default="" />
		<cfargument name="Foster_Youth" required="false" default="" />
		<cfargument name="Alt_Language_Workshop" required="false" default="" />
		<cfargument name="Alt_Languages" required="false" default="" />
		<cfargument name="Translators" required="false" default="" />
		<cfargument name="Translator_Languages" required="false" default="" />
		<cfargument name="Refreshments" required="false" default="" />
		<cfargument name="Child_Care" required="false" default="" />
		<cfargument name="Other_Services" required="false" default="" />
		<cfargument name="Other_Services_Description" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />
		<cfargument name="period" required="false" default="" />
		<cfargument name="workshopIDs" required="false" default="" />
		<cfargument name="siteIDs" required="false" default="" />
		<cfargument name="userIDs" required="false" default="" />
		<cfargument name="organizationIDs" required="false" default="" />
		<cfargument name="regionIDs" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readWorkshop">
			<cfprocparam value="#arguments.Workshop_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Workshop_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Program_Year#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Program_Year)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Approved#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Approved)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Organization_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Organization_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Organizer_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Organizer_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Site_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Site_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Manager_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Manager_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Workshop_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Workshop_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Start_Time#" cfsqltype="CF_SQL_TIME" null="#IIf(Len(Trim(arguments.Start_Time)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.End_Time#" cfsqltype="CF_SQL_TIME" null="#IIf(Len(Trim(arguments.End_Time)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Evaluation_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Evaluation_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.PB_Survey_Count#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.PB_Survey_Count)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.PB_Survey_Count_Status#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.PB_Survey_Count_Status)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.PB_Shipped_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.PB_Shipped_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.PB_Notes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.PB_Notes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Anticipated_Students#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Anticipated_Students)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Anticipated_Volunteers#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Anticipated_Volunteers)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Anticipated_Computers#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Anticipated_Computers)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Financial_Aid_Presentation#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Financial_Aid_Presentation)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAFSA_On_The_Web#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.FAFSA_On_The_Web)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Online#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Online)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Offline_Reasons#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Offline_Reasons)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Small_Group#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Small_Group)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Scholarship_Assistance#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Scholarship_Assistance)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Tax_Assistance#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Tax_Assistance)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Separate_Areas#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Separate_Areas)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.AB540#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.AB540)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Foster_Youth#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Foster_Youth)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Alt_Language_Workshop#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Alt_Language_Workshop)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Alt_Languages#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Alt_Languages)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Translators#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Translators)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Translator_Languages#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Translator_Languages)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Refreshments#" cfsqltype="CF_SQL_BIT"null="#IIf(Len(Trim(arguments.Refreshments)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Child_Care#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Child_Care)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Other_Services#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Other_Services)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Other_Services_Description#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Other_Services_Description)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<!--- period was fouling up the queries, so it is auto set to null --->
			<cfprocparam value="#arguments.period#" cfsqltype="CF_SQL_VARCHAR" null="true" />
			<cfprocparam value="#arguments.workshopIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.workshopIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.siteIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.siteIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.userIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.userIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.organizationIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.organizationIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.regionIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.regionIDs)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="workshop" required="true" type="assets.calgrants.com.bo.Workshop" />

		<cfstoredproc datasource="#getDatasource()#" procedure="saveWorkshop">
			<cfprocparam value="#workshop.getWorkshop_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#workshop.getProgram_Year()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#workshop.getApproved()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getOrganization_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#workshop.getOrganizer_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#workshop.getSite_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#workshop.getManager_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#formatShortDate(workshop.getWorkshop_Date())#" cfsqltype="CF_SQL_DATE" null="false" />
			<cfprocparam value="#workshop.getStart_Time()#" cfsqltype="CF_SQL_TIME" null="false" />
			<cfprocparam value="#workshop.getEnd_Time()#" cfsqltype="CF_SQL_TIME" null="false" />
			<cfprocparam value="#workshop.getEvaluation_Code()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#workshop.getPB_Survey_Count()#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(workshop.getPB_Survey_Count())) eq 0, true, false)#" />
			<cfprocparam value="#workshop.getPB_Survey_Count_Status()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(workshop.getPB_Survey_Count_Status())) eq 0, true, false)#" />
			<cfprocparam value="#formatShortDate(workshop.getPB_Shipped_Date())#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(workshop.getPB_Shipped_Date())) eq 0, true, false)#" />
			<cfprocparam value="#workshop.getPB_Notes()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(workshop.getPB_Notes())) eq 0, true, false)#" />
			<cfprocparam value="#workshop.getAnticipated_Students()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#workshop.getAnticipated_Volunteers()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#workshop.getAnticipated_Computers()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#workshop.getFinancial_Aid_Presentation()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getFAFSA_On_The_Web()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getOnline()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getOffline_Reasons()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(workshop.getOffline_Reasons())) eq 0, true, false)#" />
			<cfprocparam value="#workshop.getSmall_Group()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getScholarship_Assistance()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getTax_Assistance()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getSeparate_Areas()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getAB540()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getFoster_Youth()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getAlt_Language_Workshop()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getAlt_Languages()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(workshop.getAlt_Languages())) eq 0, true, false)#" />
			<cfprocparam value="#workshop.getTranslators()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getTranslator_Languages()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(workshop.getTranslator_Languages())) eq 0, true, false)#" />
			<cfprocparam value="#workshop.getRefreshments()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getChild_Care()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getOther_Services()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#workshop.getOther_Services_Description()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(workshop.getOther_Services_Description())) eq 0, true, false)#" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="Workshop_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyWorkshop">
			<cfprocparam value="#arguments.Workshop_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

